package com.lingnan.tijian.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.lingnan.tijian.domain.CheckItem;
import com.lingnan.tijian.domain.SetmealDetailed;
import com.lingnan.tijian.mapper.CheckItemMapper;
import com.lingnan.tijian.service.ICheckItemService;
import com.lingnan.tijian.service.ISetmealDetailedService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


@Service
public class CheckItemServiceImpl extends ServiceImpl<CheckItemMapper,CheckItem> implements ICheckItemService {
    @Autowired
    private CheckItemMapper checkItemMapper;

    @Autowired
    private ISetmealDetailedService setmealDetailedService;

    @Override
    public List<CheckItem> selectCheckItemListBySetmealId(Long setmealId) {
        //1.查询套餐id对应的检查组id
        List<SetmealDetailed> setmealDetailedList = setmealDetailedService.lambdaQuery()
                .eq(SetmealDetailed::getSmId, setmealId)
                .list();
        List<Long> ciIdList = setmealDetailedList.stream()
                .map(SetmealDetailed::getCiId)
                .toList();
        //2.遍历检查项id，查询检查组id对应的检查项id
        List<CheckItem> checkItemList = lambdaQuery()
                .in(CheckItem::getId, ciIdList)
                .list();
        return checkItemList;
    }
}
